package com.gym.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gym.dao.UserDao;
import com.gym.pojo.Train;
import com.gym.pojo.User;
import com.gym.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Resource
    private UserDao userDao;


    @Override
    public List<User> listUser(String name) {
        return userDao.listUser(name);
    }

    @Override
    public PageInfo<User> selListUser(String name, int index, int size) {
        PageHelper.startPage(index, size);
        PageInfo<User> page=new PageInfo<User>(userDao.listUser(name),5);
        return page;
    }

    @Override
    public PageInfo<User> selectsj(String username, int userId, int index, int size) {
        PageHelper.startPage(index,size);
        PageInfo<User> page=new PageInfo<User>(userDao.selectsj(username,userId),5);
        return page;
    }

    @Override
    public boolean insUser(User user) {
        return userDao.insUser(user)>0;
    }

    @Override
    public boolean updUser(User user) {
        return userDao.updUser(user)>0;
    }

    @Override
    public boolean delUserById(int userId) {
        return userDao.delUserById(userId)>0;
    }

    @Override
    public int selByAccount(String account) {
        return userDao.selByAccount(account);
    }

    @Override
    public boolean selUserBypwd(int userId, String pwd) {
        return userDao.selUserBypwd(userId,pwd)>0;
    }

    @Override
    public boolean updUserBypwd(int userId, String pwd) {
        return userDao.updUserBypwd(userId,pwd)>0;
    }

    @Override
    public boolean UpdMemIdById(int userId) {
        return userDao.UpdMemIdById(userId)>0;
    }

    @Override
    public int selUserIdByAcc(int account) {
        return userDao.selUserIdByAcc(account);
    }
}
